<?php
use yii\helpers\Url;
?>
<!DOCTYPE html>
<!--[if IE 8]> <html lang="en" class="ie8"> <![endif]-->
<!--[if !IE]><!-->
<html lang="en">
<!--<![endif]-->
<head>
    <meta charset="utf-8" />
    <title>百游网络游戏系统管理平台</title>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
    <meta name='viewport' content='width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no' />

    <!-- ================== BEGIN BASE CSS STYLE ================== -->
    <link href="css/app.min.css" rel="stylesheet" />
    <link href="css/login.css" rel="stylesheet" />
    <!-- ================== END BASE CSS STYLE ================== -->
    <script type="text/javascript" src="js/jquery-3.2.1.min.js"></script>
    <script type="text/javascript" src="layer/layer.js"></script>
    <script src="https://cdn.jsdelivr.net/jquery.form/3.51/jquery.form.min.js"></script>
    <script type="text/javascript" src="validator/jquery.validator.min.js?local=zh-CN"></script>
    <script type="text/javascript">
        $(function () {
            if (window.localStorage) {
                var loc = window.localStorage.getItem("UserName");
                if (loc) $("#username").val(loc);
            }
            $(".codeimg").click(function () {
                $(this).attr("src", "<?= Url::to(['/site/get-captcha'])?>?_" + Math.random());
            });
            $("#uchk").click(function () {
                var that = $(this).val();
                $(this).val(that === "0" ? 1 : 0);
            });
            var form = $(".pageForm");
            form.on('valid.form', function () {
                layer.load();
                $(this).ajaxSubmit({
                    url: form.prop("action"),
                    success: function (d) {
                        layer.closeAll('loading');
                        if (d.retcode === 200) {
                            window.localStorage.setItem("UserName", $("#username").val());
                            layer.msg(d.retmsg, {
                                success: function () {
                                    window.location.href = "<?= Url::to(['/'])?>";
                                }
                            });
                            return false;
                        }
                        layer.msg(d.retmsg);
                        $("#usercode").focus();
                        $(".codeimg").attr("src", "<?= Url::to(['/site/get-captcha'])?>? _" + Math.random());
                    }
                });
            });
            $(window).keydown(function (e) {
                var theEvent = e || window.event;
                var code = theEvent.keyCode || theEvent.which || theEvent.charCode;
                if (code == 13) {
                    $("#btnLogin").trigger("click");
                    return false;
                }
                return true;
            });
        });
    </script>
</head>
<body>
<!-- BEGIN #app -->
<div class="app app-full-height app-without-header">
    <!-- BEGIN login -->
    <div class="login" style="text-align: center">
        <!-- BEGIN login-cover -->
        <div class="login-cover"></div>
        <!-- END login-cover -->
        <!-- BEGIN login-content -->
        <div class="login-content">
            <!-- BEGIN login-brand -->
            <div class="login-brand">
                <a href="#"><b>QP</b>Management System</a>
            </div>
            <!-- END login-brand -->
            <h3 class="m-b-25"><span>百游网络游戏系统管理平台</span></h3>
            <!-- BEGIN login-desc -->
            <div class="login-desc m-b-30">
                For your protection, please verify your identity.
            </div>
            <!-- END login-desc -->
            <!-- BEGIN login-form -->
            <form class="pageForm" action="<?= Url::to(['/site/login'])?>" method="post" data-validator-option="{timely:2, theme:'yellow_top'}">
                <div class="form-group">
                    <input type="text" class="form-control" placeholder="管理账号" name="username" value="" data-rule="账号:required;length(4~18)"/>
                </div>
                <div class="form-group">
                    <input type="password" class="form-control" placeholder="密码" name="userpass" value="" data-rule="密码:required;length(6~32)"/>
                </div>
                <div class="form-group">
                    <input type="text" class="form-control" placeholder="验证码" name="usercode" id="usercode" data-rule="验证码:required;length(4)" value="" maxlength="4">
                    <img src="<?= Url::to(['/site/get-captcha'])?>" class="codeimg" title="点击刷新验证码" />
                </div>
                <div class="m-b-30">
                    <div class="checkbox-inline">
                        <input type="checkbox" id="login-remember-me" value="2"> <label for="login-remember-me">自动登录</label>
                    </div>
                </div>
                <div class="form-group">
                    <button type="submit" id="btnLogin" class="btn btn-primary width-150 btn-rounded">立即登录</button>
                </div>
            </form>
            <!-- END login-form -->
            <div class="login-desc m-t-30">
                    &copy;
                    <script>
                        document.write(new Date().getFullYear())
                    </script>
                    <a href="<?= $config['domain']->CfgVal?>" target="_blank"><?= $config['company']->CfgVal?></a>
            </div>
        </div>
        <!-- END login-content -->
    </div>
    <!-- END login -->

    <!-- BEGIN btn-scroll-top -->
    <a href="#" data-click="scroll-top" class="btn-scroll-top fade"><i class="fa fa-arrow-up"></i></a>
    <!-- END btn-scroll-top -->
</div>
<!-- END #app -->
</body>
</html>